<?php

namespace App\Http\Controllers\Api\v1;


use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;


class CeshiController extends Controller
{

    public function ceshiheader(Request $request){
        $data = $request->all();
        $phone = $data['phone'];
        $pd = $data['pd'];
        $type = $data['type'];
        $pid = $data['pid'];
        $url = "https://api-br.gbg.bet/global/v5_oeiwjd/login.php?phone=5534252345234&pd=asdqfsdfsd&type=1&pid=0";
        $response = Http::withHeaders([
            //'Content-Type' => 'application/json;charset=utf-8',
            //'User-Agent'  => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/' . (rand(20000,70000)/100) . ' (KHTML, like Gecko) Chrome/120.0.0.0 Safari/' . (rand(20000,70000) / 100) . '',
            'User-Agent'  => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
            'HTTP_X_FORWARDED_FOR' => self::randIp(),
            'CLIENT-IP' => self::randIp(),

        ])->get($url);
        $result = $response->body();//message
        print_r($result);
    }


    function randIp()
    {
        $ip2id = round(rand(600000, 2550000) / 10000); //第一种方法，直接生成
        $ip3id = round(rand(600000, 2550000) / 10000);
        $ip4id = round(rand(600000, 2550000) / 10000);

        //下面是第二种方法，在以下数据中随机抽取
        $arr_1 = array('218','218','66','66','218','218','60','60','202','204','66','66','66','59','61','60','222','221','66','59','60','60','66','218','218','62','63','64','66','66','122','211');
        $randarr = mt_rand(0,count($arr_1)-1);
        $ip1id = $arr_1[$randarr];

        $ip = $ip1id . '.' . $ip2id . '.' . $ip3id . '.' . $ip4id;
        return $ip;
    }


}
